package team.nmsg.ge.system.init;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 使用@WebListener注解，实现ServletContextListener接口
 * 初始化 Tomcat 获取 J2EE application
 */
@WebListener
public class SysServletContextListener implements ServletContextListener {

	private static Logger logger =  LoggerFactory.getLogger(  SysServletContextListener.class );
	
	public static ServletContext j2eeApplication; 
	
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		logger.debug("SysServletContextListener.contextDestroyed");
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		logger.debug("SysServletContextListener.contextInitialized");
		
		ServletContext servletContext = arg0.getServletContext();
		j2eeApplication = servletContext;
	}
}
